import * as dayjs from 'dayjs';
import 'dayjs/locale/zh-cn';
import * as timezone from 'dayjs/plugin/timezone';
import * as utc from 'dayjs/plugin/utc';
import type { Dayjs } from 'dayjs';

(dayjs as any).extend(utc);
(dayjs as any).extend(timezone);
(dayjs as any).locale('zh-cn');

export const today = dayjs().format('YYYY-MM-DD')

/** 格式化时间 YYYY-MM-DD HH:mm:ss */
export const formatTime = (
  time: Date | Dayjs = dayjs(),
  formatString = 'YYYY-MM-DD HH:mm:ss',
) => {
  return dayjs(time).tz('Asia/Shanghai').format(formatString);
};

/** 对比时间是否相同 */
export const compareTime = (date1: string, date2: string) => {
  return dayjs(date1).isSame(dayjs(date2))
}



